<?php
require_once 'models/models_banner.php';
$mod = $_GET['mod'];
$obbn = new models_banner();	
switch ($mod){
	case 'banner':{
		$data['list'] = $obbn->_listbanner();
		//echo var_dump($data);
		require_once 'views/admin/banner/index.php';
		break;
	}
	case 'addbanner':{
		if($_POST){
		if (isset($_FILES))
					{
						move_uploaded_file($_FILES['hinhanh']['tmp_name'], 'public/images/'.$_FILES['hinhanh']['name']);
						$Hinh = $_FILES['hinhanh']['name'];
					}
       $obbn->_addbanner($Hinh, $_POST['anhien']);
			echo '<script> window.location.href="admin.php?mod=banner"</script>';
		}
		require 'views/admin/banner/add.php';
		break;
	}
	case 'delbanner':{
		$obbn->_delbanner($_GET['ma']);
		echo '<script>window.location.href="admin.php?mod=banner"</script>';
		break;
	}
	case 'updatebanner':{
		if($_POST){
		if (isset($_FILES))
					{
						move_uploaded_file($_FILES['hinh']['tmp_name'], 'public/images/'.$_FILES['hinh']['name']);
						$Hinh = $_FILES['hinh']['name'];
					}
			$obbn->_updatebanner($Hinh, $_POST['anhien'], $_GET['ma']);
			echo '<script>window.location.href="admin.php?mod=banner"</script>';
		}
		$data = $obbn->_getbanner($_GET['ma']);
		require 'views/admin/banner/edit.php';
		break;
	}
	default: {echo  'Yêu cầu chưa được xử lý !'; break;}
	}
?>